<?php

/**
 * This is the model class for table "paymentinformation".
 *
 * The followings are the available columns in table 'paymentinformation':
 * @property integer $id
 * @property integer $idManagement
 * @property integer $idRentalProperty
 * @property integer $MethodOfPayment
 * @property string $BankInformation
 * @property string $RoutingNumber
 * @property string $AccountNumber
 * @property string $CCNumber
 * @property string $ExpirationDate
 * @property integer $CCVNumber
 * @property string $NameOnCard
 * @property string $OneTimeOrReccurring
 * @property string $DatePaymentPrefferenceSet
 * @property string $PayPalAccount
 *
 * The followings are the available model relations:
 * @property Rentalproperty $idRentalProperty0
 * @property Landlord $idManagement0
 */
class Paymentinformation extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Paymentinformation the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'paymentinformation';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('idManagement, idRentalProperty, MethodOfPayment, CCVNumber', 'numerical', 'integerOnly'=>true),
			array('BankInformation, PayPalAccount', 'length', 'max'=>45),
			array('RoutingNumber, AccountNumber', 'length', 'max'=>15),
			array('CCNumber', 'length', 'max'=>20),
			array('ExpirationDate', 'length', 'max'=>5),
			array('NameOnCard', 'length', 'max'=>30),
			array('OneTimeOrReccurring', 'length', 'max'=>1),
			array('DatePaymentPrefferenceSet', 'safe'),
			array('MethodOfPayment, OneTimeOrReccurring','required'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, idManagement, idRentalProperty, MethodOfPayment, BankInformation, RoutingNumber, AccountNumber, CCNumber, ExpirationDate, CCVNumber, NameOnCard, OneTimeOrReccurring, DatePaymentPrefferenceSet, PayPalAccount', 'safe', 'on'=>'search'),
		);
		
		
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idRentalProperty0' => array(self::BELONGS_TO, 'Rentalproperty', 'idRentalProperty'),
			'idManagement0' => array(self::BELONGS_TO, 'Landlord', 'idManagement'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'idManagement' => 'Id Management',
			'idRentalProperty' => 'Id Rental Property',
			'MethodOfPayment' => 'Method Of Payment',
			'BankInformation' => 'Bank Information',
			'RoutingNumber' => 'Routing Number',
			'AccountNumber' => 'Account Number',
			'CCNumber' => 'Ccnumber',
			'ExpirationDate' => 'Expiration Date',
			'CCVNumber' => 'Ccvnumber',
			'NameOnCard' => 'Name On Card',
			'OneTimeOrReccurring' => 'One Time Or Reccurring',
			'DatePaymentPrefferenceSet' => 'Date Payment Prefference Set',
			'PayPalAccount' => 'Pay Pal Account',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('idManagement',$this->idManagement);
		$criteria->compare('idRentalProperty',$this->idRentalProperty);
		$criteria->compare('MethodOfPayment',$this->MethodOfPayment);
		$criteria->compare('BankInformation',$this->BankInformation,true);
		$criteria->compare('RoutingNumber',$this->RoutingNumber,true);
		$criteria->compare('AccountNumber',$this->AccountNumber,true);
		$criteria->compare('CCNumber',$this->CCNumber,true);
		$criteria->compare('ExpirationDate',$this->ExpirationDate,true);
		$criteria->compare('CCVNumber',$this->CCVNumber);
		$criteria->compare('NameOnCard',$this->NameOnCard,true);
		$criteria->compare('OneTimeOrReccurring',$this->OneTimeOrReccurring,true);
		$criteria->compare('DatePaymentPrefferenceSet',$this->DatePaymentPrefferenceSet,true);
		$criteria->compare('PayPalAccount',$this->PayPalAccount,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}